package website.digitalocean.chapter2;

/**
 * 工厂模式
 *
 * @author: longhc@citycloud.com.cn
 * @since: 2023/2/9 17:10
 * @version: 1.0
 */
public class ComputerFactory {

    public static Computer getComputer(String type, String ram, String hdd, String cpu) {
        if ("pc".equalsIgnoreCase(type)) {
            return new Pc(ram, hdd, cpu);
        } else if ("server".equalsIgnoreCase(type)) {
            return new Server(ram, hdd, cpu);
        }
        return null;
    }
}
